package com.moli.iov.manager.service.impl;

import com.moli.iov.cache.RedisUtil;
import com.moli.iov.manager.ManagerConstant;
import com.moli.iov.manager.model.dto.DictMap;
import com.moli.iov.manager.model.dto.DictParam;
import com.moli.iov.manager.service.DictDataRemoteService;
import com.moli.iov.rest.RestResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName DictDataRemoteServiceImpl
 * @Description TODO
 * @Author 李伟松
 * @CreateDate 2019-06-28 下午 4:48
 * @UpdateDate 2019-06-28 下午 4:48
 * @Version 1.0
 */
@Service("dictDataRemoteService")
public class DictDataRemoteServiceImpl implements DictDataRemoteService {

    @Resource
    RedisUtil redisUtil;

    @Override
    public RestResponse<DictMap> getDictMap(DictParam param) {
        DictMap dto = new DictMap();
        if(param!=null){
            Map<String,String> map = new HashMap<>();
            List<String> list = redisUtil.hgetString(ManagerConstant.DICT_MAP_TYPE, param.get());
            if(list!=null && list.size()>0){
                for (String value : list) {
                    dto.put(value);
                }
            }
        }
        return RestResponse.success(dto);
    }
}
